package qst.com.bacK.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import qst.com.bacK.service.WeatherService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * Author:   msh
 * Date:     2024/10/14 下午11:44
 * Description:
 */

@Controller
public class WeatherController {
    @Autowired
    private WeatherService weatherService;

    @GetMapping("/weather")
    public void getWeather(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        // 从Service层获取天气数据
        Map weather = weatherService.queryWeather("东莞");
        req.getSession().setAttribute("weather", weather);
        resp.sendRedirect("/welcome.jsp");
    }
}
